package com.onpositive.wiki3.db.catmodel.matches;

import com.carrotsearch.hppc.IntOpenHashSet;
import com.onpositive.wiki3.db.catmodel.Category;
import com.onpositive.wiki3.db.catmodel.ICategoryMatcher;

public class LeafsRemover implements ICategoryMatcher {

	IntOpenHashSet pp = new IntOpenHashSet();

	@Override
	public int accept(Category st) {
		if (!st.hasChildren()) {
			if (pp.contains(st.id())){
				return 0;
			}
			int[] parents = st.getParents();
			for (int q:parents){
				pp.add(q);
			}
			st.remove();
			
		}
		return 0;
	}

}
